package com.yuandian.management.enums;

import java.io.Serializable;

/**
 * 协议protocol
 *
 * @author User
 */
public enum ProtocolEnum implements Serializable {
	/**
	 * 协议protocol
	 */
	HTTP("1", "HTTP"),
	TNS("2", "TNS"),
	TUXEDO("3", "TUXEDO"),
	GIOP("4", "GIOP"),
	SPARK("5", "SPARK"),
	MQ("6", "MQ"),
	TCP("7", "TCP"),
	UDP("8", "UDP"),
	TDS("9", "TDS"),
	MYSQL("10", "MYSQL"),
	DB2("11", "DB2"),
	CICS("12", "CICS"),
	AJP("13", "AJP"),
	REMOTE("14", "REMOTE"),
	SOCKET("15", "SOCKET"),
	REDIS("16", "REDIS"),
	T3("17", "T3"),
	MQTT("18", "MQTT"),
	SSL("19", "SSL"),
	OPENWIRE("20", "OPENWIRE"),
	AMQP("21", "AMQP"),
	DUBBO("22", "DUBBO");

    private String code;
    private String message;
    /**
     * 协议个数
     */
    public static final Integer PROTOCOL_SIZE = ProtocolEnum.values().length;

    private ProtocolEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getProtocolEnumValue(String key) {
		for (ProtocolEnum protocolEnum : ProtocolEnum.values()) {
			if (protocolEnum.getCode().equals(key.trim())) {
				return protocolEnum.getMessage();
			}
		}
		throw new IllegalArgumentException("Invalid enum Code: " + key);
    }

    @Override
    public String toString() {
        return this.code + "_" + this.message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
